<?php
/**
 * Author: Traveler
 * Time  : 2021/12/25 0025 15:56
 */

namespace app\validate;

use app\ErrorCode;
use think\Validate;

class DepartmentValidate extends Validate
{
    /**
     * 验证规则
     *
     * @var string[]
     */
    protected $rule = [
        'name'   => 'require|max:16|unique:\\app\\model\\DepartmentModel',
        'status' => 'require|in:0,1'
    ];

    /**
     * 提示信息
     *
     * @var string[]
     */
    protected $message = [
        'name.require'   => ErrorCode::REQUIRE_DEPARTMENT_NAME,
        'name.max'       => ErrorCode::INVALID_DEPARTMENT_NAME_LEN,
        'name.unique'    => ErrorCode::DUPLICATE_DEPARTMENT_NAME,
        'status.require' => ErrorCode::REQUIRE_DEPARTMENT_STATUS,
        'status.in'      => ErrorCode::INVALID_DEPARTMENT_STATUS,
    ];
}